package work6;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class DouDiZhu {
    ArrayList<Puke> arrayList = new ArrayList<>();
    public void goujian(ArrayList arrayList, String type) {//构建扑克牌
        for (int i = 3; i <= 15; i++) {
            if (i == 11) {
                arrayList.add(new Puke("J", type, 11));
                continue;
            }
            if (i == 12) {
                arrayList.add(new Puke("Q", type, 12));
                continue;
            }
            if (i == 13) {
                arrayList.add(new Puke("K", type, 13));
                continue;
            }
            if (i == 14) {
                arrayList.add(new Puke("A", type, 14));
                continue;
            }
            if (i == 15) {
                arrayList.add(new Puke("2", type, 15));
                continue;
            }
            arrayList.add(new Puke( i  + " ",type,i));

        }

    }



    public void init() {
        goujian(arrayList, "黑桃");
        goujian(arrayList, "红桃");
        goujian(arrayList, "方片");
        goujian(arrayList, "梅花");
        arrayList.add(new Puke("小鬼", "clown1", 16));
        arrayList.add(new Puke("大鬼", "clown2", 17));
    }




    public void shuffle() {
        Collections.shuffle(arrayList);
    }


    public void sendCard() {
        List<Puke> ArrayList1 = arrayList.subList(0, 17);
        Collections.sort(ArrayList1, new Comparator<Puke>() {
            @Override
            public int compare(Puke o1, Puke o2) {
                return o1.getC() - o2.getC();
            }
        });
        for (Puke puke : ArrayList1) {
            System.out.println(puke.getType()+puke.getPoint());
        }
    }


    public void star(){
        init();
        shuffle();
        sendCard();
    }




}
    


